#include "ScopePrinter.h"

#include<iostream>
#include<string>

using namespace std;

string g_asType[]=
{
    "Invalid",
    "Global",
    "Paren",
    "CC",
    "CPP",
    "Block",
    "Bracket",
    "ePrep" //FIXME Remove this. This is actually intelligence?
};

int g_nIndent = 0;

void tabify()
{
    for(int i=0;i<g_nIndent;i++)
        cout<<" ";
}


ScopePrinter::ScopePrinter(void)
{
}

ScopePrinter::~ScopePrinter(void)
{
}

void ScopePrinter::onNewToken(Token& inToken)
{
//    cout<<inToken.m_sValue;
}


void ScopePrinter::onScopeEntry(Scope& inNewScope, Scope& inOldScope)
{
//    cout<<endl;
    tabify();
    cout<<"<<SCOPE>>"<<g_asType[inOldScope.m_eType]<<"-->"<<g_asType[inNewScope.m_eType]<<endl;
    g_nIndent++;
    tabify();
}

void ScopePrinter::onScopeExit(Scope& inNewScope, Scope& inOldScope)
{
//    cout<<endl;
    tabify();
    cout<<"<<SCOPE>>"<<g_asType[inOldScope.m_eType]<<"-->"<<g_asType[inNewScope.m_eType]<<endl;
    g_nIndent--;
    tabify();
}

